{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {
    "toc": true
   },
   "source": [
    "<h1>02-pass语句及其作用<span class=\"tocSkip\"></span></h1>\n",
    "<div class=\"toc\"><ul class=\"toc-item\"></ul></div>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "pass 是 Python 中的关键字，用来让解释器跳过此处，什么都不做。"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    " 它适合当语法上需要一条语句但并不需要执行任何代码时用来临时占位，例如:\n",
    "\n",
    "`def f(arg): pass    # a function that does nothing (yet)`\n",
    "\n",
    "`class C: pass       # a class with no methods (yet)`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "请输入你的年龄：30\n"
     ]
    }
   ],
   "source": [
    "age = int(input('请输入你的年龄：'))\n",
    "\n",
    "if age < 12:\n",
    "    print('儿童')\n",
    "elif age >= 12 and age < 18:\n",
    "    print('青少年')\n",
    "elif age >= 18 and age < 30:\n",
    "    print('成年人')\n",
    "elif age >= 30 and age < 50:\n",
    "    pass\n",
    "else:\n",
    "    print('老人')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "使用 pass 语句比使用注释更加优雅。"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "02-pass语句及其作用",
   "title_sidebar": "Contents",
   "toc_cell": true,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": true
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
